/* @(#)GSBalanceFeeProcessor.java    V0.1
 *
 * Project: GS
 *
 * Modify Information:
 * =============================================================================
 *   Author       Date       Description
 *   ------------ ---------- ---------------------------------------------------
 *   owen         2006-5-17
 *
 * Copyright Notice:
 * =============================================================================
 *    Copyright (c) 2001-2006 Beijing HiTRUST Technology Co., Ltd. 1808 Room, 
 *        Science & Technology Building, No. 9 South Street, Zhong Guan Cun, 
 *        Haidian District, Beijing ,100081, China All rights reserved.
 *
 *    This software is the confidential and proprietary information of
 *        Beijing HiTRUST Technology Co., Ltd. ("Confidential Information").
 *        You shall not disclose such Confidential Information and shall use it
 *        only in accordance with the terms of the license agreement you entered
 *        into with HiTRUST.
 *
 * Warning:
 * =============================================================================
 * 
 */
package com.hitrust.gs.business;

import java.util.ArrayList;

import com.hitrust.gs.bean.GSBalanceCategoryBean;

import com.hitrust.gs.dao.GSBalanceCategoryDAO;
import com.hitrust.gs.lib.GSLogWriter;
import com.hitrust.gs.service.GSBaseProcesser;
import com.hitrust.gs.util.exception.GSException;

/**
 * 
 */
public class GSBalanceCategoryProcessor implements GSBaseProcesser{
   /**
    * 增加结算类型任务
    * @param aGSBalanceCategoryBean
    * @throws GSException
    */
    public static void addTask(GSBalanceCategoryBean aGSBalanceCategoryBean)throws GSException {
        GSBalanceCategoryDAO tGSBalanceCategoryDAO = new GSBalanceCategoryDAO();
           
        String maxid = tGSBalanceCategoryDAO.queryMaxID();
        maxid = Integer.toString(Integer.parseInt(maxid) + 1);
        aGSBalanceCategoryBean.setGs_balance_category_no(maxid);
        if (tGSBalanceCategoryDAO.add(aGSBalanceCategoryBean) == false) {
            throw new GSException("增加结算类型失败!");
        }
    }
    /**
     * 修改结算类型任务
     * @param aGSBalanceCategoryBean
     * @throws GSException
     */
    public static void modifyTask(GSBalanceCategoryBean aGSBalanceCategoryBean)throws GSException {
        GSBalanceCategoryDAO tGSBalanceCategoryDAO = new GSBalanceCategoryDAO();
           
            if (tGSBalanceCategoryDAO.modify(aGSBalanceCategoryBean) == false) {
                throw new GSException("修改结算类型失败!");
            }
        }
    
    /**
     * 得到所有的结算类型
     * @return
     * @throws GSException
     */
    public static ArrayList getAllCategoryType()throws GSException{
        GSBalanceCategoryDAO tGSBalanceCategoryDAO = new GSBalanceCategoryDAO();
        
        ArrayList tArrayList=new ArrayList();
        try {
            //通过机构编号和机构名称查询所有机构信息
            ArrayList  tBalanceCategoryList=tGSBalanceCategoryDAO.queryAllBalanceCategory();
            if (tBalanceCategoryList.size() > 0) {
                
                for (int i = 0; i < tBalanceCategoryList.size(); i++) {

                    GSBalanceCategoryBean tGSBalanceCategoryBean = (GSBalanceCategoryBean) tBalanceCategoryList.get(i);
                    String[] tStr = new String[3];
                    tStr[0] = tGSBalanceCategoryBean.getGs_balance_category_no();
                    tStr[1] = tGSBalanceCategoryBean.getGs_balance_category_name();
                    tStr[2] = tGSBalanceCategoryBean.getGs_desc();
                    
                    tArrayList.add(tStr);
                    
                }
            }
            
        } catch (GSException e) {
            GSLogWriter.error("GSBalanceCategoryProcessor GSException: " +e.toString());
        }
        return tArrayList;
    }
    /**
     * 得到所有的结算类型信息
     * 
     * @param aCategoryTypeNo
     *            机构编号
     * @throws GSException          
     */
    public static GSBalanceCategoryBean getCategory(String aCategoryTypeNo)throws GSException{
        GSBalanceCategoryDAO tGSBalanceCategoryDAO = new GSBalanceCategoryDAO();
        
        GSBalanceCategoryBean tGSBalanceCategoryBean = new GSBalanceCategoryBean();  
        try {
            tGSBalanceCategoryBean=tGSBalanceCategoryDAO.queryBalanceCategory(aCategoryTypeNo);
        } catch (GSException e) {
            GSLogWriter.error("GSBalanceCategoryProcessor GSException: " +e.toString());
        }
        return tGSBalanceCategoryBean;
    }
    /**
     * 删结算类型信息
     * @param aGSBalanceCategoryBean
     * @throws GSException
     */
    public static void delTask(String aTypeNo)throws GSException {
        GSBalanceCategoryDAO tGSBalanceCategoryDAO = new GSBalanceCategoryDAO();
           
            if (tGSBalanceCategoryDAO.delete(aTypeNo) == false) {
                throw new GSException("删除结算类型失败!");
            }
        }
}
